1 00:00:01,520 --> 00:00:01,850 Okay. 2 00:00:01,850 --> 00:00:06,350 So in this video, we're going to continue working on our donut tool by creating an eating animation 3 00:00:06,350 --> 00:00:06,920 for it. 4 00:00:07,160 --> 00:00:11,900 In order to create animations on roadblocks, we first have to create a model that represents a player's 5 00:00:11,900 --> 00:00:12,770 character model. 6 00:00:12,770 --> 00:00:17,210 So when we create an animation, it knows exactly which limbs to perform the animation on. 7 00:00:17,510 --> 00:00:21,470 To create a character model, we can go to the Avatar tab. 8 00:00:22,820 --> 00:00:24,560 And select the Rig Builder button. 9 00:00:25,860 --> 00:00:30,630 From here we can select an AR 15 block rig and spot it in front of us. 10 00:00:30,990 --> 00:00:35,460 And I'll just make sure that this rig is level with the ground so we can see what we're doing. 11 00:00:35,640 --> 00:00:40,950 Now that I have my character model, I'm going to make my tool a child of my model. 12 00:00:41,220 --> 00:00:42,900 That way my model equips it. 13 00:00:42,900 --> 00:00:44,700 The character equips the tool. 14 00:00:45,060 --> 00:00:46,830 So as you can see, it is equipped. 15 00:00:46,830 --> 00:00:47,520 My donut. 16 00:00:49,690 --> 00:00:53,440 Then I can open up the animation editor in the Avatar tab. 17 00:00:54,220 --> 00:00:59,200 I'll close out the console here real quick and then I can select this rig, this character to start 18 00:00:59,200 --> 00:01:00,160 animating it. 19 00:01:00,820 --> 00:01:02,140 It'll ask you to name it. 20 00:01:02,140 --> 00:01:04,000 I'll just name it eating. 21 00:01:04,360 --> 00:01:07,720 And now we can start animating our dummy here, our rig. 22 00:01:08,080 --> 00:01:13,000 So here you have a timeline that starts at zero and goes all the way up to one second. 23 00:01:13,000 --> 00:01:17,920 And of course, we can increase how long we want this animation to be, but one second long should be 24 00:01:17,920 --> 00:01:18,700 good for now. 25 00:01:19,210 --> 00:01:24,490 And in this case, since we're going to be doing an eating animation, I want to animate the head and 26 00:01:24,490 --> 00:01:26,050 the right arm of the model. 27 00:01:26,260 --> 00:01:31,180 So using this little plus button here, I'll add the head as a part. 28 00:01:31,180 --> 00:01:40,100 I want to animate and I'll add the right lower arm, the right upper arm and the right hand as well. 29 00:01:40,120 --> 00:01:41,980 I want to animate everything in the arm. 30 00:01:42,960 --> 00:01:48,000 Now, at the beginning here, we want to define a starting position for our animation. 31 00:01:48,150 --> 00:01:55,290 And as you know, when we hold a tool in Roblox, it starts off the character with their arm at a 90 32 00:01:55,290 --> 00:01:56,010 degree angle. 33 00:01:56,010 --> 00:01:58,580 This is how the character looks when they hold a tool. 34 00:01:58,590 --> 00:02:01,500 This is just the default way of holding tools and roadblocks. 35 00:02:01,740 --> 00:02:04,700 So we want to make sure we start off at this default pose. 36 00:02:04,710 --> 00:02:11,280 Otherwise, if we didn't, if we had the arm down at the resting position here, then when this animation 37 00:02:11,280 --> 00:02:16,770 gets run, it'll move our arm back down and then back up to perform the eating animation, which will 38 00:02:16,770 --> 00:02:18,200 look a little strange. 39 00:02:18,210 --> 00:02:22,020 So I'm going to put it at the 90 degree position for now. 40 00:02:23,130 --> 00:02:30,090 Now I kind of want to start maybe around here, I guess, is where we can start rotating the arm towards 41 00:02:30,090 --> 00:02:31,220 the character's head. 42 00:02:31,230 --> 00:02:33,360 So I'll just rotate the arm here. 43 00:02:34,460 --> 00:02:40,760 And then maybe I want to rotate this part of the arm so I have it rotate towards the face and then have 44 00:02:40,760 --> 00:02:43,160 the hand rotate towards the face as well. 45 00:02:44,710 --> 00:02:45,010 And I'll. 46 00:02:45,310 --> 00:02:47,350 I'll move this whole thing a little bit more. 47 00:02:47,560 --> 00:02:49,270 Maybe this one a little bit more. 48 00:02:50,750 --> 00:02:51,200 Okay. 49 00:02:51,200 --> 00:02:54,620 And then I want to have my arm move up so it's actually towards my mouth. 50 00:02:56,000 --> 00:03:02,480 And since the donuts a little offset to my mouth, I maybe want to move my arm kind of like that. 51 00:03:03,980 --> 00:03:06,140 So now the donuts kind of in my mouth. 52 00:03:06,860 --> 00:03:11,900 So when I go to the start of my animation here at 0 seconds and then hit spacebar to play it, you see 53 00:03:11,900 --> 00:03:14,450 it moves the donut towards my mouth. 54 00:03:16,100 --> 00:03:17,630 And maybe I want it to be a little slower. 55 00:03:17,640 --> 00:03:23,130 Salt drag all these keyframes by using this top keyframe here, which selects all the ones below it. 56 00:03:24,550 --> 00:03:25,960 And that looks a little better. 57 00:03:27,100 --> 00:03:32,650 So now that the donut is in my face, I want the head to move down and look like it's biting the donut. 58 00:03:35,610 --> 00:03:38,940 And so here I can select my head. 59 00:03:40,200 --> 00:03:42,030 And have it rotate down a little. 60 00:03:43,280 --> 00:03:48,650 And then maybe a little bit later, it rotates back up to the starting position. 61 00:03:51,940 --> 00:03:55,600 Now if I play it, it kind of looks like my character is eating it. 62 00:03:55,600 --> 00:04:01,990 And if you've noticed throughout this entire track here, if we go along frame by frame, you'll notice 63 00:04:01,990 --> 00:04:04,600 my head is moving down the whole time, which I don't want. 64 00:04:04,960 --> 00:04:11,470 And that's because after this default head keyframe right here, it starts animating my head towards 65 00:04:11,470 --> 00:04:13,480 the other head keyframe I defined here. 66 00:04:13,480 --> 00:04:18,640 So if I want to keep my head still, I'll just copy this keyframe and paste it for however long I want 67 00:04:18,640 --> 00:04:19,780 to keep the head still. 68 00:04:19,780 --> 00:04:24,640 And then once it reaches past this key frame right here, then the head will start moving down. 69 00:04:26,450 --> 00:04:31,070 And it does it a little bit too quick so I can select these key frames here, kind of move them out 70 00:04:31,070 --> 00:04:31,670 a bit. 71 00:04:38,400 --> 00:04:38,730 Here we go. 72 00:04:38,730 --> 00:04:42,420 We kind of got like a goofy little E.T. animation. 73 00:04:42,960 --> 00:04:46,920 And then afterwards, I want to make sure my arm goes back to the default holding position. 74 00:04:46,920 --> 00:04:51,030 So I'll just copy all these keyframes and move them, like down here. 75 00:04:53,300 --> 00:04:59,480 And I want to make sure that my arm stays at this position here until my head is done moving. 76 00:04:59,480 --> 00:05:06,200 So I'll copy all this and move it to here, copy all this, move it to here. 77 00:05:06,410 --> 00:05:11,450 Because otherwise, if I don't, if I didn't have those key frames here, then my arm would start moving 78 00:05:11,450 --> 00:05:13,270 back when I don't want it to. 79 00:05:13,280 --> 00:05:16,070 So it'll look like I'm kind of biting air. 80 00:05:16,400 --> 00:05:19,800 So I want to make sure I copy all these key frames and move it here. 81 00:05:19,820 --> 00:05:25,610 Then after all these key frames are reached, it'll start animating towards the next set of key frames. 82 00:05:26,440 --> 00:05:28,030 So now if we play the whole thing. 83 00:05:29,550 --> 00:05:31,080 Looks like I'm eating my donut. 84 00:05:32,640 --> 00:05:38,760 Now, another cool thing we can do with animations is add an event, and this event will fire when the 85 00:05:38,760 --> 00:05:41,330 animation plays and it reaches that event point. 86 00:05:41,340 --> 00:05:46,920 So for example, here, maybe when the head bites down, like right here, when the head bites down, 87 00:05:46,920 --> 00:05:53,010 I can right click the track and add an animation event and I can name it like bite. 88 00:05:54,430 --> 00:05:56,380 And you can put whatever parameter in here. 89 00:05:56,380 --> 00:05:58,150 I'm just going to leave it blank for now. 90 00:05:58,270 --> 00:06:04,810 But basically, when the animation plays in our script, when it reaches this animation event point, 91 00:06:04,810 --> 00:06:08,910 it will fire this event and then we can connect a script to do whatever we like. 92 00:06:08,920 --> 00:06:13,390 So for example, maybe I can play an eating sound when this event fires. 93 00:06:13,780 --> 00:06:21,850 So I move my arm to my mouth and then the head moves down this event fire so that I can play an eating 94 00:06:21,850 --> 00:06:22,570 sound. 95 00:06:24,300 --> 00:06:27,540 And the head goes back up and the arm returns to the default position. 96 00:06:27,990 --> 00:06:33,870 Another thing I can do with my keyframes is that I can right click them and change the easing style 97 00:06:33,870 --> 00:06:34,470 of them. 98 00:06:34,590 --> 00:06:39,930 So maybe instead of it being linear, which means the movement of the arm is constant, which isn't 99 00:06:39,930 --> 00:06:43,980 exactly natural, I can change it to something like cubic. 100 00:06:45,230 --> 00:06:47,540 And I can actually do it for all of my keyframes. 101 00:06:47,540 --> 00:06:51,620 If I make it cubic, you'll see how the animation will look a little bit different. 102 00:06:52,010 --> 00:06:54,350 So now if I play my animation. 103 00:06:57,140 --> 00:07:00,770 You can kind of see how my arm doesn't move in a linear fashion anymore. 104 00:07:02,950 --> 00:07:06,330 And maybe, let's see what other easing styles we can do. 105 00:07:06,340 --> 00:07:08,230 Maybe I can do elastic. 106 00:07:08,410 --> 00:07:10,470 And we'll give it an elastic like a rubber band. 107 00:07:10,480 --> 00:07:10,990 Look. 108 00:07:11,960 --> 00:07:13,400 That looks really weird. 109 00:07:14,850 --> 00:07:17,340 And I can change the easing direction. 110 00:07:17,880 --> 00:07:19,620 Maybe I want to do in and out. 111 00:07:21,660 --> 00:07:24,060 And maybe I want to put it back to Cubic. 112 00:07:26,610 --> 00:07:27,000 Look at that. 113 00:07:27,000 --> 00:07:28,440 That looks a little more natural. 114 00:07:31,690 --> 00:07:34,610 And we'll take a couple of look at another one like bounce. 115 00:07:34,630 --> 00:07:36,520 It'll make my arms look like they're bouncing. 116 00:07:39,380 --> 00:07:41,180 But I think I'm going to keep it at Kubik for now. 117 00:07:41,860 --> 00:07:46,900 If you want to learn more about easing styles and easing directions, then I'll attach a robotics article 118 00:07:46,900 --> 00:07:49,120 to this lecture so you can learn more about them. 119 00:07:49,700 --> 00:07:54,200 But for now, I think we have a pretty good animation here that we can use for our donut. 120 00:07:55,390 --> 00:08:01,450 So now what we want to do is want to hit these three little dots here and we want to change the animation 121 00:08:01,450 --> 00:08:02,050 priority. 122 00:08:02,050 --> 00:08:07,830 And what this basically means is what priority does this animation have over other animations? 123 00:08:07,840 --> 00:08:12,040 So, for example, you know, the character has like default animations, like when it's walking. 124 00:08:12,070 --> 00:08:14,690 It has a default animation when it equips a tool. 125 00:08:14,710 --> 00:08:19,300 What priority do we want to set this animation over other animations? 126 00:08:19,300 --> 00:08:24,010 And we want to set this animation to action because we're performing an action here. 127 00:08:24,190 --> 00:08:30,370 If we didn't set this animation priority to action, then when we try to play the animation, the default 128 00:08:30,370 --> 00:08:36,100 holding animation where your arm sticks out, which I believe has an animation priority of idle, if 129 00:08:36,100 --> 00:08:40,120 we didn't have this track at an animation priority of movement or higher. 130 00:08:41,520 --> 00:08:43,200 And you have different levels of action. 131 00:08:43,200 --> 00:08:47,970 So maybe you have multiple different action animations and you want them to have higher precedence over 132 00:08:47,970 --> 00:08:49,440 other action animations. 133 00:08:49,740 --> 00:08:52,980 So Redbox Studio gives us the option to do that here. 134 00:08:53,400 --> 00:08:58,290 Now we can publish our animation and use it by hitting the published roadblocks button. 135 00:08:59,230 --> 00:09:02,350 And then I'll just name it eating donut. 136 00:09:05,930 --> 00:09:07,220 Then I can hit submit. 137 00:09:08,400 --> 00:09:13,830 Now you have to copy the ID in the link to use your animation so you can go to this link and open up 138 00:09:13,830 --> 00:09:18,510 your browser and copy the number to your clipboard and then come back once you've got your number. 139 00:09:19,800 --> 00:09:24,180 Now that you have your number copied, we're going to go to our tool here and we're going to remove 140 00:09:24,180 --> 00:09:26,760 it from our dummy and put it back into the workspace. 141 00:09:26,910 --> 00:09:29,640 And then we don't need our dummy anymore, so I'll just delete them. 142 00:09:30,610 --> 00:09:32,800 And then I'll fix the orientation of my donut. 143 00:09:36,330 --> 00:09:41,610 And then inside my donut, I'm going to insert a new object, a new animation object. 144 00:09:43,300 --> 00:09:48,250 And inside the animation there's this animation ID property and you're going to want to paste the number 145 00:09:48,250 --> 00:09:49,840 you copied from your link. 146 00:09:50,650 --> 00:09:55,720 Now that we have our animation in our tool, we can now implement the animation in our script, our 147 00:09:55,720 --> 00:09:58,700 local script, and we'll get to do that in the next lecture. 148 00:09:58,720 --> 00:09:59,740 I'll see you there.